import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx';
import Unocss from 'unocss/vite'
import cesium from 'vite-plugin-cesium';
import { presetUno, presetAttributify, presetIcons } from 'unocss'
import { resolve } from 'path'
import Components from 'unplugin-vue-components/vite'
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue({
      reactivityTransform: true,
    }),
    vueJsx(),
    Unocss({
      presets: [presetUno(), presetAttributify(), presetIcons()],
    }),
    Components({
      resolvers: [AntDesignVueResolver()],
    }),
    cesium(),
  ],
  server: {
    proxy: {
      "/api" : {
        target: "http://localhost:9999",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ""),
      }
    }
  },
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src'),
      'vue': 'vue/dist/vue.esm-bundler.js',
    },
  },
  css: {
    preprocessorOptions: {
      less: {
        charset: false,
        additionalData: '@import "@/style/global/index.less";',
        javascriptEnabled: true,
      },
    },
  },
  build: {
    target: 'es2015',
    outDir: 'dist',
    reportCompressedSize: false, // 启用/禁用 gzip 压缩大小报告
    chunkSizeWarningLimit: 1024, // chunk 大小警告的限制（单位kb）
  },
})
